import 'package:network_test/Models/Oil_Price.dart';

class ResultData1 {
  var resultcode;
  var reason;
  var result;
  int? error_code;

  ResultData1({
    this.resultcode,
    this.reason,
    this.result,
    this.error_code,
  });

  //ResultData1(this.resultcode, this.reason, this.result, this.error_code,{this.headers, resultcode});
  //JSON解析工厂类，使用字典数据为对象初始化赋值
  factory ResultData1.fromJson(Map<String, dynamic> parsedJson) {
    ResultData1 tmp = ResultData1(
      resultcode: parsedJson['resultcode'],
      reason: parsedJson['reason'],
      error_code: parsedJson['error_code'],
    );

    if (parsedJson['result'] is List) {
      //print(parsedJson['result']);
      List<Oil_Price> result = [];
      for (var item in parsedJson['result']) {
        result.add(Oil_Price.fromJson(item));
      }
      tmp.result = result;

    } else {
      tmp.result = parsedJson['result'];
    }

    return tmp;
  }
}

class ResultData {
  var data;
  bool isSuccess;
  int code;
  var headers;

  ResultData(this.data, this.isSuccess, this.code, {this.headers});
}
